﻿using System.Data.Entity.ModelConfiguration;
using yiCommerce.Core.Domain.Products;
using yiCommerce.Core.Domain.Shops;

namespace yiCommerce.Data.Mapping.Shops
{
    public class ShopMapping : EntityTypeConfiguration<Shop>
    {

        public ShopMapping()
        {
            this.ToTable("Shop");
            this.HasKey(c => c.Id);
            this.Property(u => u.ShopName).HasMaxLength(1000);


            this.HasRequired(b => b.Owner)
                .WithMany()
                .HasForeignKey(b => b.CustomerId);


            this.HasMany(b => b.Products)
                .WithRequired(p => p.Shop);

            this.HasMany(b => b.Orders)
                .WithRequired(p => p.Shop);
        }
    }
}